home *** CD-ROM | disk | FTP | other *** search
/ Amiga News 95 / Amiga News 95.iso / dpat / dpat12 / enterenv / enterenv.c < prev    next >
C/C++ Source or Header  |  1992-10-28  |  2KB  |  76 lines

  1.  
  2. /*
  3. **      $Application name : EnterEnv $
  4. **      $Revision : 1.1 $
  5. **      $Release : 1.01 $
  6. **      $Date : 92/10/28 $
  7. **
  8. **
  9. **
  10. **      (C) Copyright 1992 David Scrève
  11. **          All Rights Reserved
  12. */
  13.  
  14. /* this software was compiled with SAS/C 5.10b Compiler. */
  15. /* to Recompile this C source code, you need the include V37 or higher */
  16. /* Contact the Commodore Amiga Technical Support for more information */
  17.  
  18. #include <stdio.h>
  19. #include "dos/dos.h"
  20.  
  21. struct FileHandle *my_Handle;
  22. struct Library *DosBase,*OpenLibrary();
  23.  
  24. void DOAction(ArgVector,ArgNumber)
  25. char **ArgVector;
  26. int ArgNumber;
  27. {
  28.  char my_text[256];
  29.  char EnvValue[256]=" ";
  30.  LONG Resultat;
  31.  
  32.  ArgVector++;
  33.  strcpy(my_text,"env:");
  34.  strcat(my_text,*ArgVector);
  35.  if (DosBase=(struct Library *)OpenLibrary("dos.library",37L))
  36.      {
  37.       my_Handle=(struct FileHandle *)Open(&my_text[0],MODE_NEWFILE);
  38.       if (my_Handle!=NULL)
  39.           {
  40.            if (ArgNumber==3)
  41.                {
  42.                 ArgVector++;
  43.                 printf("\n%s",*ArgVector);
  44.                }
  45.            gets(&EnvValue[0]);
  46.            Resultat=Write(my_Handle,&EnvValue[0],strlen(EnvValue));
  47.            if (Resultat==-1)
  48.                 printf("\nUne Erreur d'écriture s'est produite.\n");
  49.            Close(my_Handle);
  50.           }
  51.         else
  52.           printf("\nImpossible d'ouvrir le fichier.\n");
  53.        CloseLibrary(DosBase);
  54.       }
  55.     else
  56.      printf("\n La Dos.library Version 37 m'est vitale. Je meurs...\n");
  57. }
  58.  
  59. void WriteMessage()
  60. {
  61.  printf("\nEnterEnv Release 1.01 By David Scrève. CopyRight (c) 1992");
  62.  printf("\nThis Software is freely distributable with the complete package.\n");
  63.  printf("\nSyntax : EnterEnv <Name of the Env Variable> [<Text message>]\n\n");
  64. }
  65.  
  66.  
  67. main(argc,argv)
  68. int argc;
  69. char **argv;
  70. {
  71.  if (argc==1 || (argc==2 && (*argv[0]=='h' || *argv[0]=='H' || *argv[0]=='?')))
  72.       WriteMessage();
  73.      else
  74.       DOAction(argv,argc);
  75. }
  76.